package it.scambiocorse.rowmapper;

import it.scambiocorse.model.AreaType;
import it.scambiocorse.utils.Utils;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

public class AreaRowMapper implements RowMapper  {

	  public Object mapRow(ResultSet rs, int row) throws SQLException {
	    AreaType area= new AreaType();
	    try {
			    area.setIdArea(rs.getInt("id_area"));
			    area.setIdOwner(rs.getInt("id_user_owner"));
			    area.setNomeArea(Utils.isValid(rs.getString("nome_area")) ? rs.getString("nome_area") : "");
			    area.setTipoArea(rs.getInt("id_area"));
		} catch (SQLException e) {
			if (e.getSQLState().equals("S0022")) {
				//logger.debug("Colonna non trovata, mappaggio non necessario");
			} else {
				throw e;
			}
		}
	    
	    return area;
	  }

	

}
